import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
import tailwindcss from "tailwindcss"

const _resolve = (dir: string) => path.resolve(__dirname, dir)

const isProd = process.env['NODE_ENV'] === 'development'

// https://vitejs.dev/config/
export default defineConfig({
  root: '.',
  base: './',
  plugins: [react()],
  css: {
    postcss: {
      plugins: [tailwindcss]
    }
  },
  // 配置项目别名
  resolve: {
    alias: {
      '@': _resolve('src'),
      '@hook': _resolve('src/hooks'),
      '@conf': _resolve('src/assets/conf'),
      '@component': _resolve('src/components'),
    },
  },
  server: {
    // proxy: isProd ? {
    //   '/apis': {target: 'http://moretime.fun'}
    // } : {
    //   '/apis/auth': {target: 'http://localhost:9901'},
    //   '/apis/cron': {target: 'http://localhost:9902'},
    //   '/apis/ledger': {target: 'http://localhost:9903'},
    // }
  }
})
